
#include "rmfileDispose.h"

void rmfileDispose(char * spath , int sockfd){
    char command[] = "remove";
    Train train;
    train.length = strlen(command);
    memcpy(train.data,command,train.length);
    send(sockfd,&train,sizeof(train.length)+train.length,MSG_NOSIGNAL);
    
    train.length = strlen(spath);
    memcpy(train.data,spath,train.length);
    send(sockfd,&train,sizeof(train.length)+train.length,MSG_NOSIGNAL );
    
    int epollfd = epoll_create(1);
    struct epoll_event event;
    event.data.fd = sockfd;
    event.events = EPOLLIN;
    epoll_ctl(epollfd,EPOLL_CTL_ADD,sockfd,&event);
    struct epoll_event readyset[5];
    epoll_wait(epollfd,readyset,5,-1);

    char c;
    recv(readyset[0].data.fd,&c,1,MSG_WAITALL);

    if(c == '1'){
        printf("删除失败！不存在该文件\n");
    }else if(c == '2'){
        printf("删除失败！非普通文件！\n");
    }else if(c == '0'){
        printf("删除成功！\n");
    }

    return ;
}
